package com.ligongmusic.util;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

import com.ligongmusic.R;
import com.ligongmusic.activity.MusicActivity;

public class NotificationUtils {
	//创建通知  
    public void CreateInform(Context mContext, String title, int layoutId) {  
        //定义一个PendingIntent，当用户点击通知时，跳转到某个Activity(也可以发送广播等)  
        Intent intent = new Intent(mContext, MusicActivity.class);  
        PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);  
        //创建一个通知  
//        Notification notification = new Notification(R.drawable.ic_launcher, "正在播放" + playIng, System.currentTimeMillis());  
        Notification notification = new Notification();
        notification.icon = R.drawable.ic_launcher;
        notification.contentView = new RemoteViews(mContext.getPackageName(), layoutId);
//        notification.setLatestEventInfo(mContext, "点击查看", "点击查看详细内容", pendingIntent);  
        //用NotificationManager的notify方法通知用户生成标题栏消息通知  
        NotificationManager nManager = (NotificationManager) mContext.getSystemService(mContext.NOTIFICATION_SERVICE);  
        nManager.notify(100, notification);//id是应用中通知的唯一标识  
        //如果拥有相同id的通知已经被提交而且没有被移除，该方法会用更新的信息来替换之前的通知。  
    }
}
